﻿@{var currentEnterprise = Session["SELECTED-ENTERPRISE"] as SecurityApi.Model.Enterprise; }

<br />
<h3>SELECT AN APPLICATION TO WORK WITH</h3>
<br />
@(Html.Kendo().Grid<SecurityApi.Model.Application>()
    .Name("ApplicationsGrid")
    .HtmlAttributes(new { style = "height:500px;" })
    .Columns(columns =>
    {

        //columns.Template(o => @Html.ActionLink("Select", "SelectApplication","Application",new { appId = o.ApplicationId }, null)).Width(50);

        columns.Template(@<text></text>).ClientTemplate("<a href='" + Url.Content("~/Application/SelectApplication/?") + "appId= #= ApplicationId #'" + ">Select</a>") //always use Url.Content to get the correct relative path
                    .Title("").Width(100);

        columns.Bound(c => c.ApplicationId).Width(100).Title("Id");

        columns.Bound(c => c.Name);


    })
    .Pageable()
    .Sortable()
    .Selectable()
    .Resizable(resize => resize.Columns(true))
    .Reorderable(reorder => reorder.Columns(true))
    .Filterable()
    .Scrollable()
    .DataSource(dataSource => dataSource
        .Ajax()
        .PageSize(50)
        .Model(model => model.Id(p => p.ApplicationId))
        .Read(read => read.Action("AjaxEnterpriseApplications", "Application", new {enterpriseId=@currentEnterprise.Id }))
    )
)
